package com.galudisu.client

import akka.actor.{ActorSystem, PoisonPill, Props}
import akka.cluster.singleton.{ClusterSingletonManager, ClusterSingletonManagerSettings, ClusterSingletonProxy,
ClusterSingletonProxySettings}
import com.typesafe.config.ConfigFactory

object StatsSampleOneMaster {
  def main(args: Array[String]): Unit = {
    // Override the configuration of the port when specified as program argument
    val config = ConfigFactory.load("server")

    val system = ActorSystem("ClusterSystem", config)

    //#create-singleton-manager
    system.actorOf(ClusterSingletonManager.props(
      singletonProps = Props[ClusterServer],
      terminationMessage = PoisonPill,
      settings = ClusterSingletonManagerSettings(system).withRole("server")),
      name = "statsServer")
    //#create-singleton-manager

    //#singleton-proxy
    system.actorOf(ClusterSingletonProxy.props(singletonManagerPath = "/user/server",
      settings = ClusterSingletonProxySettings(system).withRole("server")),
      name = "statsServerProxy")
    //#singleton-proxy


  }
}
